// Copyright (C) 2007 Content (Data Extraction Magazine)
// http://www.Content.com, support@Content.com
//
// This code is provided AS IS, with NO WARRANTY expressed or implied.
// Any use of this free open source code is at your own risk.
//
// You are hereby granted the right to use it and change it,
// provided that you acknowledge Content somewhere in your
// source files, documentation, web site and application.

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Content.ImageEditor
{
    /// <summary>
    /// Show the Thumbnail image of a ImageEdit object
    /// </summary>
    public partial class ThumbnailControl : UserControl
    {
        public ThumbnailControl()
        {
            InitializeComponent();
        }

        #region Image

        /// <summary>
        /// Associated ImageEdit object
        /// </summary>
        public ImageEdit Thumbnail
        {
            get { return _thumbnail; }
            set
            {
                _thumbnail = value;
                if (_thumbnail == null)
                    _thumbnail = new ImageEdit();
                ShowPicture();
            }
        }

        // Redraw thumbnail on resize
        private void pnlMain_Resize(object sender, EventArgs e)
        {
            ShowPicture();
        }

        /// <summary>
        /// Pass the thumbnail image to pctMain PictureBox
        /// </summary>
        private void ShowPicture()
        {
            Image thumbnail = _thumbnail.Thumbnail;

            pctMain.Image = thumbnail;
        }
        #endregion
    }
}
